/**
 * 
 */
package info.niwota.web.ac;

import android.accounts.AccountManager;
import android.app.Activity;
import android.os.Bundle;
import android.view.Window;
import android.view.WindowManager;
import android.widget.Toast;

/**
 * @author qiangli
 * 
 */
public class CreateAccountActivity extends Activity {

	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);

		requestWindowFeature(Window.FEATURE_NO_TITLE);
		getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
				WindowManager.LayoutParams.FLAG_FULLSCREEN);
		
		createGoogleAccount();
		
		finish();
	}

//	@SuppressWarnings("unused")
//	private void createAccount() {
//		try {
//			Intent i = new Intent("android.settings.ADD_ACCOUNT_SETTINGS");
//			i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
//			startActivity(i);
//		} catch (Error e) {
//			Toast.makeText(this, e.getMessage() + "", Toast.LENGTH_SHORT)
//					.show();
//
//			e.printStackTrace();
//		}
//	}

	private void createGoogleAccount() {
		try {
			AccountManager am = AccountManager.get(this);
			am.addAccount("com.google", null, null, null, this, null, null);
		} catch (Error e) {
			//TODO https://accounts.google.com/SignUp
			Toast.makeText(this, e.getMessage() + "", Toast.LENGTH_SHORT)
					.show();

			e.printStackTrace();
		}
	}
}
